package org.xtext.runtime.type;

public class ObjectType implements IType {
	public static final IType type = new ObjectType(Object.class);
	
	private Class<?> clazz;
	
	public ObjectType(Class<?> clazz) {
		this.clazz = clazz;
	}
	
	public String type() {
		return "object";
	}
	
	public boolean typeCheck(Object obj) {
		return (clazz.isInstance(obj));
	}
	
	public String toString() {
		return "object<" + clazz.getCanonicalName() + ">";
	}

	@Override
	public boolean matches(IType type) {
		if (ObjectType.class.isInstance(type)) {
			return clazz.isAssignableFrom(((ObjectType) type).clazz);
		}
		return false;
	}
}
